home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / June 96 / Re Reading Formatted Text < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  2.5 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Reading Formatted Text
  2. Sent:        6/11/96 8:27 AM
  3. Received:    6/11/96 9:12 AM
  4. From:        Serge Froment, sfroment@odyssee.net
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. >As you've noticed, ODF R1 doesn't provide anything that exactly meets your
  9. >needs. FW_CTextReader is the most appropriate ODF class for this task.  The
  10. >idea is to create tool classes that use TextReader interfaces.  For
  11. >example, you might write a lexical analyzer class along these lines:
  12.  
  13. Jim:
  14.  
  15. Thank you for your detailed answer. I ended up doing somewhat what you
  16. said, using FW_CTextReader::PeekRunAhead to copy the text inside a
  17. FW_CString where I can search for delimiters. Here is the code a came up
  18. with:
  19.  
  20. void CMyData::ReadString(FW_CTextReader& textReader, FW_CString& string,
  21. FW_LChar delimiter)
  22. {
  23.         const char* start;
  24.         FW_Boolean seeking = true;
  25.         FW_ByteCount length, del, eol, size = 0;
  26.  
  27.         string.Truncate(0);
  28.         do
  29.         {
  30.                 textReader.PeekRunAhead(start, length);
  31.                 if (length > 0)
  32.                 {
  33.                         string.Append(start, length);
  34.                         if (string.FindCharacter(delimiter, del, size))
  35.                         {
  36.                                 string.Truncate(del);
  37.                                 if (string.FindCharacter('\r', eol, size))
  38.                                 {
  39.                                         string.Truncate(eol);
  40.                                         textReader.Advance(eol - size);
  41.                                 }
  42.                                 else
  43.                                         textReader.Advance(del - size + 1);
  44.                                 seeking = false;
  45.                         }
  46.                         else if (string.FindCharacter('\r', eol, size))
  47.                         {
  48.                                 string.Truncate(eol);
  49.                                 textReader.Advance(eol - size);
  50.                                 seeking = false;
  51.                         }
  52.                         else
  53.                                 textReader.Advance(length);
  54.                         size = string.GetByteLength();
  55.                 }
  56.         }
  57.         while (seeking && length > 0);
  58. }
  59.  
  60. However, I am a bit concerned about the efficiency of such a method in the
  61. case the clipboard contain a large text. (I was done writing the code late
  62. last evening and I have not yet tested what happen in that case.)
  63.  
  64. Serge
  65.  
  66.